package com.wc.AlgoOJ_train.train2_DP训练.c3.DP0107;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/13 0:27
 * @description 二维背包
 * http://43.138.190.70:8888/p/DP0107
 */
public class Main {
    static int maxN = 100 + 7;
    static int[] ws = new int[maxN];
    static int[] vs = new int[maxN];
    static int[] rs = new int[maxN];
    static int[][] dp = new int[maxN][maxN];
    static int n, m, r;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        r = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
            rs[i] = sc.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = m; j >= ws[i]; j--) {
                for (int k = r; k >= rs[i]; k--) {
                    dp[j][k] = Math.max(dp[j][k], dp[j - ws[i]][k - rs[i]] + vs[i]);
                }
            }
        }
        out.println(dp[m][r]);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}